<template>
  <view class="page">
    <Header> </Header>
    <view class="main_container">
      <view class="main_content">
        <Breadcrumb :text="'同步句子-句子听选-听力训练'"> </Breadcrumb>
        <RouterTabs :list="routerList" :current="0"> </RouterTabs>
        <view class="content">
          <Listen
            ref="listen"
            :bookInfo="bookChapter"
            :list="sentenceList"
            @view="hanldeView"
          ></Listen>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { findSentenceList } from "@/api/hearing";
export default {
  components: {},
  beforeRouteLeave(to, from, next) {
    this.$refs.listen.suspend();
    next();
  },
  data() {
    return {
      routerList: [
        {
          name: "句子听选",
          url: "pages/sentence/sentenceChoice",
        },
        {
          name: "句子拼写",
          url: "pages/sentence/sentenceTranslation",
        },
        {
          name: "句子跟读",
          url: "pages/sentence/sentenceRead",
        },
      ],
      chapterId: "",
      bookChapter: {},
      sentenceList: [],
    };
  },
  onLoad(option) {
    this.chapterId = option.chapterId;
    this.init();
  },
  methods: {
    init() {
      let params = {
        id: this.chapterId,
      };
      findSentenceList(params).then((res) => {
        this.sentenceList = res.data.list;
        this.bookChapter = res.data.bookChapter;
      });
    },
    hanldeView() {
      uni.navigateTo({
        url: `/pages/sentence/sentenceChoiceDetail?chapterId=${this.chapterId}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./sentenceChoiceListen";
</style>
